/**
 * 获取指定日期当月最后一天的日期
 * @param date 
 * @returns Date
 */
export function getMonthLastDay(date: Date | string): Date {
    date = new Date(date);
    let y = date.getFullYear();
    let m = date.getMonth();
    let lastDate = new Date(y, m + 1, -1);
    return lastDate
}

/**
 * 获取指定日期当月第一天的日期
 * @param date 
 * @returns 
 */
export function getMonthFirstDay(date: Date | string): Date {
    date = new Date(date);
    let y = date.getFullYear();
    let m = date.getMonth();
    let firstDate = new Date(y, m, 1);
    return firstDate
}

/**
 * 获取指定日期当年第一天的日期
 * @param date 
 * @returns 
 */
export function getYearFirstDay(date: Date | string): Date {
    date = new Date(date);
    let y = date.getFullYear();
    let result = new Date(y, 0, 1);
    return result
}

/**
 * 获取指定日期当年最后天的日期
 * @param date 
 * @returns 
 */
export function getYearLastDay(date: Date | string): Date {
    date = new Date(date);
    let y = date.getFullYear();
    let result = new Date(y, 11, 31);
    return result
}